using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Storage;
using Microsoft.Xna.Framework.Content;

namespace WarPigs
{
    public class dgcFPS : DrawableGameComponent
    {
        private float _ElapsedTime, _TotalFrames, _Fps;
        private bool _ShowFPS;
        private Game mGame;

        public bool ShowFPS
        {
            get { return _ShowFPS; }
            set { _ShowFPS = value; }
        }

        public dgcFPS(Game game)
            : base(game)
        {
            mGame = game;
        }

        public override void Initialize()
        {
            base.Initialize();
        }

        protected override void LoadContent()
        {


            base.LoadContent();
        }

        public override void Update(GameTime gameTime)
        {
            base.Update(gameTime);

            _ElapsedTime += (float)gameTime.ElapsedGameTime.TotalSeconds;
            _TotalFrames++;

            if (_ElapsedTime >= 1.0f)
            {
                _Fps = _TotalFrames;
                _TotalFrames = 0;
                _ElapsedTime = 0;
            }

            mGame.Window.Title = _Fps.ToString();
        }

        public override void Draw(GameTime gameTime)
        {
            base.Draw(gameTime);
        }
    }
}